<template>
  <div>
    <div class="hotwork">
          <ul>
              <li v-for="(attention,index) in myattention" :key="index">
                  <div class="pic">
                    <img :src="'http://120.48.37.120:9000/parttime/'+attention.companypic" alt="">
                  </div>
                  <div class="job">
                      <span class="jobs">{{attention.companyname}}</span>
                      <span class="attention">{{attention.comadvantage}}</span>
                  </div>
                  
                  <div class="btn" >
                      <el-button type="success" @click="RecruitDetail(attention.id)">查看详情</el-button>
                  </div>
              </li>
          </ul>
      </div>
      <div class="page">
      <!-- 分页区域 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.pagenum"
        :page-sizes="[1, 5, 8, 10]"
        :page-size="queryInfo.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data(){
    return{
      myattention:{},
      total:0,
      //获取分页列表的参数
      queryInfo:{
          pagenum:1,
          pagesize:5
      },

    }
  },
  created(){
    this.getYonghu()
  },
  methods:{
    async getYonghu() {
      this.user = JSON.parse(window.sessionStorage.getItem('user'))
      const { data: res } = await this.$http.get(
        'userByUsername?username=' + this.user.username
      )
      if (res.meta.status != 200) return this.$message.error(res.meta.msg)
      this.yonghu = res.data
      this.getMyAttention()
    },
    //监听pagesize改变的事件
    handleSizeChange(newSize) {
      this.queryInfo.pagesize = newSize
      this.getYonghu()
    },
    //监听页码值改变的数据
    handleCurrentChange(newPage) {
      this.queryInfo.pagenum = newPage
      this.getYonghu()
    },
    async getMyAttention(){
      const {data:res}=await this.$http.get("getAllAttentionByUsername?username="+this.yonghu.username,{params:this.queryInfo})
      this.myattention=res.data.records
      this.total = res.data.total
      console.log(this.myattention);
    },
    async RecruitDetail(id){
        window.sessionStorage.setItem("comid",id)
        console.log(id);
        this.$router.push("/CompanyDetail")

    }

  }

}
</script>

<style lang="less" scoped>
.hotwork{
    li{
        
        padding: 10px 0px 0 20px;
        list-style-type:none;
        background-color: pink;
        width: 90%;
        height: 145px;
        margin-bottom: 10px;
        background-color: #fff;
        border-radius: 10px;
        .pic{
            width: 100px;
            height: 120px;
            margin-right: 5%;
            img{
                width: 100%;
                height: 100%;
            }
        }
        .job{
            margin-top: 15px;
            width: 50%;
        }
        .company{
            width: 33%;
        }
        .btn{
            float: right;
            padding-right: 116px;
            padding-top: 30px;
            
        }
        .jobs{
            font-size: 22px;
            font-weight:700;
            display: block;
            margin-bottom: 10px;
        }
        .attention{
            background-color: #F6F7F8;
            padding: 5px 10px 5px 10px;
            color: #666666;
            font-size: 10px;
            margin:6px 0 10px 6px;
            float: left;
            border-radius: 10px;
        }
        .salary{
            font-size: 20px;
            font-weight:600;
            display: block;
            margin-bottom: 10px;
            color: red;
        }
        .eduname{
            font-size: 14px;
            margin-bottom: 10px;
            color: #7D6695;
            background-color: #F6F7F8;
            text-align: center;
            border-radius: 12px;
            padding:5px 8px 5px 8px;
        }
        .company{
            padding-left: 20px;
        }
        .companyname{
            font-size: 18px;
            margin: 22px 0 15px 0;
            font-weight:700;
        }
        .placename{
            color: #999999;
        }
        div{
            float: left;
        }
        span{
            display: block;
        }

    }
    li:hover{
        box-shadow: 1px 1px 5px #888888;
    }
    el-pagination{
      margin-left: 20%;
    }
}
</style>